package io.renren.modules.vastFinance.controller;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.vastFinance.entity.RepaymentlogEntity;
import io.renren.modules.vastFinance.service.RepaymentlogService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 还款日志表
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2022-05-23 12:11:18
 */
@RestController
@RequestMapping("vastFinance/repaymentlog")
public class RepaymentlogController {
    @Autowired
    private RepaymentlogService repaymentlogService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("vastFinance:repaymentlog:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = repaymentlogService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{repaymentId}")
    @RequiresPermissions("vastFinance:repaymentlog:info")
    public R info(@PathVariable("repaymentId") Integer repaymentId){
		RepaymentlogEntity repaymentlog = repaymentlogService.getById(repaymentId);

        return R.ok().put("repaymentlog", repaymentlog);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("vastFinance:repaymentlog:save")
    public R save(@RequestBody RepaymentlogEntity repaymentlog){
		repaymentlogService.save(repaymentlog);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("vastFinance:repaymentlog:update")
    public R update(@RequestBody RepaymentlogEntity repaymentlog){
		repaymentlogService.updateById(repaymentlog);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("vastFinance:repaymentlog:delete")
    public R delete(@RequestBody Integer[] repaymentIds){
		repaymentlogService.removeByIds(Arrays.asList(repaymentIds));

        return R.ok();
    }

}
